package com.hugeyurt.mapper;

import com.hugeyurt.po.Course;
import com.hugeyurt.po.EnrollCourse;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CourseMapper
{
    @Select("select * from course where cno=#{cid}")
    public Course getCourseById(Integer cid);

    @Select("select * from course")
    public List<Course> getAllCourse();

    @Insert("insert into enrollcourse(cno,sno,time)values(#{cno}," +
            "#{sno},#{time})")
    public boolean saveEnrollCourse(EnrollCourse  enrollCourse );

    @Select("select count(*) from enrollcourse where cno=#{cid}")
    public Integer getEnrollNumbers(Integer cid);

   @Select("select id from enrollevent where #{time}>=startTime and #{time}<=endtime  and status=0")
    public Integer checkStatus(String time);

   @Update("update enrollevent set status=1 where id=#{id}")
   public boolean updateEnrollEvent(Integer id);
}
